//
//  TransitionStudy.swift
//  NaiCha
//
//  Created by 唐安坤 on 2024/9/5.
//

import SwiftUI

struct TransitionStudy: View {
    @State var isShow = true
    
    var body: some View {
        VStack {
            RoundedRectangle(cornerSize: CGSize(width: 30, height: 30),style: .circular)
                .frame(width: 300, height: 150, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                .foregroundColor(.orange)
                .overlay {
                    Text("嗨，欢迎学习").font(.system(size: 30,weight: .bold)).foregroundColor(.white)
                }
            if(isShow){
                RoundedRectangle(cornerSize: CGSize(width: 30, height: 30),style: .circular)
                    .frame(width: 300, height: 150, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                    .foregroundColor(.yellow)
                    .overlay {
                        HStack{
                            Text("SwiftUI课程").font(.system(size: 30,weight: .bold)).foregroundColor(.white)
                            Image(systemName: "face.smiling.inverse")
                                .font(.system(size: 40))
                                .foregroundColor(.white)
                        }
                        
                    }.transition(.asymmetric(insertion: .move(edge: .bottom).combined(with: .opacity), removal: .move(edge: .bottom).combined(with: .opacity)))
            }
           
        }.onTapGesture {
            withAnimation(Animation.linear) {
                isShow = !isShow
            }
            
        }
    }
}

#Preview {
    TransitionStudy()
}
